package com.example.config;

import com.example.config.model.ListConfig;
import com.example.config.model.MapConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class test {
    @RequestMapping("/hello")
    public String hello(){
        return "hello...";
    }

    @Value("${name}")
    private String name;
    @RequestMapping("/readConfig")
    public String readConfig(){
        return "读取到:" + name;
    }

    @Value("${age}")
    private int age;
    @RequestMapping("/readAge")
    public String readAge(){
        return "读取到:" + age;
    }

    @Value("${str1}")
    private String str1;
    @Value("${str2}")
    private String str2;
    @Value("${str3}")
    private String str3;

    @RequestMapping("/readStr")
    public void readStr(){
        System.out.println(str1);
        System.out.println(str2);
        System.out.println(str3);
        return;
    }

    @Autowired
    private ListConfig listConfig;

    @RequestMapping("/readList")
    public String readList(){
        return listConfig.toString();
    }

    @Autowired
    private MapConfig mapConfig;

    @RequestMapping("/readMap")
    public String readMap(){
        return mapConfig.toString();
    }
}
